<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改页面</title>
</head>
<body>
<h1>修改列表</h1>
<form th:action="@{/update}" method="POST">
    <input name="id" type="hidden" th:value="${supplierContact.id}">
    <p>
        联系人姓名：<input name="cname" type="text" th:value="${supplierContact.cname}">
    </p>
    <p>
        联系人年龄：<input name="age" type="text" th:value="${supplierContact.age}">
    </p>
    <p>
        手机号：<input name="mobile" type="text" th:value="${supplierContact.mobile}">
    </p>
    <p>
        创建日期：<input name="createdate" type="datetime-loca"
                        th:value="${#dates.format(supplierContact.createdate,'yyyy-MM-dd')}">
    </p>
    <p>
        所属供应商：
        <select name="pid">
            <option value="0">--请选择--</option>
            <option value="3">小米</option>
            <option value="4">腾讯</option>
            <option value="5">百度</option>
        </select>
    </p>
    <p>
        <input type="submit" value="修改">
    </p>
</form>

</body>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:inline="javascript">

    $(function () {
        let pid = parseInt('${supplierContact.pid}')
        console.log(pid)
        if (pid == 0) {
            $("input[name='pid'][value='0']").val('--请选择--');
        } else if (pid == 1) {
            $("input[name='pid'][value='1']").val('小米');
        } else if (pid == 2) {
            $("input[name='pid'][value='2']").val('腾讯');
        } else if (pid == 3) {
            $("input[name='pid'][value='3']").val('百度');
        }
    })
</script>
</html>
